#include<stdio.h>
#include<unistd.h>
#include <sys/wait.h>
#include<sys/types.h>

void func()
{
	printf("i am child process\n");
}


int main(int argc ,char * argv[])
{
	pid_t pid = fork();

	if(pid == 0)
	{
		func();
		sleep(5);
	}
	else if(pid > 0)
	{
		int status = 0;
		pid_t ret = waitpid(-1, &status, 0);//阻塞式等待，等待5S
		
		printf("进程退出码：%d\n",WEXITSTATUS(status));
		printf("进程退出信号：%d\n",WTERMSIG(status));
		printf("coredump标志位：%d\n",((status >> 7) & 0x1));
	}
	return 0;
}
